package com.sansheng.web;

import com.sansheng.entity.user.User;
import com.sansheng.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author 陈龙
 * @version 2017年09月10日 14时51分
 */
@Controller
@EnableAutoConfiguration
@RequestMapping("/test")
public class TestController {

    @Autowired
    private UserService userService;

    @RequestMapping("/list")
    public String list() {
        List<User> list = userService.listUser();
        for (User user : list) {
            System.out.println(user);
        }
        return "index";
    }

    @RequestMapping("/add")
    public String add() {
        User user = new User();
        user.setIdentity(0);
        user.setNikName("龙歌");
        user.setSex("男");
        user.setPhone("13632376593");
        user.setQqID("260688741");
        userService.add(user);
        return "add";
    }
}
